package com.juc.reentrantlock;

import java.util.concurrent.locks.ReentrantLock;

public class ReentrantLockTest1 {

	/**
	 * 可以重入
	 */
	static ReentrantLock lock = new ReentrantLock();
	public static void main(String[] args) {
		try {
			lock.lock();
			System.out.println("enter main");
			m1();
		} finally {
			lock.unlock();
		}
	}
	
	public static void m1() {
		try {
			lock.lock();
			System.out.println("enter m1");
			m2();
		} finally {
			lock.unlock();
		}
	}
	
	public static void m2() {
		try {
			lock.lock();
			System.out.println("enter m2");
		} finally {
			lock.unlock();
		}
	}
	
}
